﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using NJamb.Specifications;
using Stile.Patterns.SelfDescribingPredicates;
using Stile.Patterns.SelfDescribingPredicates.Evaluators;
#endregion

namespace NJamb.Parser.SpecificationBuilders.SubjectIs.Extensions
{
    public static class IsExtensions
    {
        public static TSpecifies Null<TSubject, TSpecifies>(this IFluentIs<TSubject?, TSpecifies> collaboratingIs)
            where TSubject : struct where TSpecifies : class, ISpecification
        {
            Negated negated = collaboratingIs.Xray.Negated;
            var evaluator = new Evaluator<TSubject?>(new ExpectedClause<TSubject?>(null, negated),
                new ActualClause<TSubject?>(),
                x => (x == null) != negated);
            return collaboratingIs.Xray.SpecificationBuilder.Specify(evaluator);
        }

        public static TSpecifies Null<TSubject, TSpecifies>(this IFluentIs<TSubject, TSpecifies> collaboratingIs)
            where TSubject : class where TSpecifies : class, ISpecification
        {
            Negated negated = collaboratingIs.Xray.Negated;
            var evaluator = new Evaluator<TSubject>(new ExpectedClause<TSubject>(null, negated),
                new ActualClause<TSubject>(),
                x => (x == null) != negated);
            return collaboratingIs.Xray.SpecificationBuilder.Specify(evaluator);
        }
    }
}
